home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Updaters / Symantec C++⁄MPW 6.0.1 / SCpp 6.0.1 Update / SCBin / SCcreateMake
Encoding:
Text File  |  1993-08-02  |  14.2 KB  |  508 lines  |  [TEXT/MPS ]

  1. #    SCcreateMake - create a program makefile
  2. #
  3. #    Usage:
  4. #        SCcreateMake ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] |
  5. #                   -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ]
  6. #                   [ -c creator ] [-sym on] | -SIOW [ -c creator] [ -sym on ])
  7. #                    [ -mc68020 | -mc68881 | -elems881] 
  8. #                -PO -SL program file…
  9. #
  10. #    Script CreateMake creates a simple MakeFile for building the specified
  11. #    program.  The program parameter is the name of the program.  Makefile
  12. #    <program>.make is created.  The default program type is Application.
  13. #    The program may be written in any combination of Assembly Language, C, C++
  14. #    Pascal, and/or Rez.    The list of files may include both source in
  15. #    these languages and library object files that don't appear below.
  16. #
  17. #    SCcreateMake links the program with the following set of MPW Libraries:
  18. #
  19. #        Inside Macintosh Interfaces
  20. #            {Libraries}Interface.o    
  21. #    
  22. #        Runtime support - one of the following:
  23. #            {Libraries}Stubs.o        # building a tool
  24. #            {Libraries}Runtime.o         # no C object files
  25. #
  26. #        C Libraries - if any source is in C
  27. #            {SCLibraries}SClibc.o
  28. #            {CLibraries}CSANELib.o
  29. #            {CLibraries}Math.o
  30. #
  31. #        C++ Libraries - if any source is in C++
  32. #            {SClibraries}SClibc.o        
  33. #            {SClibraries}SClibcpp.o
  34. #            {SCLibraries}SCStreamsIO.o
  35. #            {CLibraries}CSANELib.o
  36. #            {CLibraries}Math.o
  37. #
  38. #        Pascal Libraries - if any source is in Pascal
  39. #            {PLibraries}PasLib.o
  40. #            {PLibraries}SANELib.o
  41. #
  42. #        For tools:
  43. #            {Libraries}ToolLibs.o
  44. #
  45. #        For desk accessories:
  46. #            {Libraries}DRVRRuntime.o
  47. #
  48. #        For programs using pascal objects:
  49. #            {Libraries}objlib.o
  50. #
  51. #
  52. #    Copyright Symantec, Inc. 1987 - 1992
  53. #    All rights reserved.
  54.  
  55. Set Exit 0
  56. Set CaseSensitive 0
  57. Set type Application
  58. Set creator '????'
  59. Set runtime '{Libraries}Runtime.o'
  60. Set interface '{Libraries}Interface.o'
  61. Set cFloatLib '{CLibraries}CSANELib.o {CLibraries}Math.o'
  62. Set cplusFloatLib '{CLibraries}CSANELib.o {CLibraries}Math.o' 
  63. Set pFloatLib '{PLibraries}SANELib.o'                        
  64. Unset sources clibs plibs toollibs DRVRRuntime resource objects program suffix typ
  65. Unset cSeen tSeen rtSeen mSeen multipleType typeSpec CPls CLang symarg symseen compileOptions
  66. Unset hardwardFloat cCompileOptions cppCompileOptions pCompileOptions multipleHWOptions 
  67. Unset cppseen objlibs streamslib
  68.  
  69. #    Collect the script parameters.
  70. Loop
  71.     Break if {#} == 0
  72.     If "{1}" =~ /-application/
  73.         Set type Application
  74.         Unset toollibs
  75.         If {typeSpec} == 0
  76.             Set typeSpec 1
  77.         Else
  78.             Set multipleType 1
  79.         End
  80.         shift 1
  81.         continue
  82.     Else If "{1}" =~ /-tool/
  83.         Set type Tool
  84.         Set toollibs '{Libraries}ToolLibs.o'
  85.         If {typeSpec} == 0
  86.             Set typeSpec 1
  87.         Else
  88.             Set multipleType 1
  89.         End
  90.         shift 1
  91.         continue
  92.     Else If "{1}" =~ /-da/
  93.         Set type DA
  94.         Unset toollibs
  95.         If {typeSpec} == 0
  96.             Set typeSpec 1
  97.         Else
  98.             Set multipleType 1
  99.         End
  100.         shift 1
  101.         continue
  102.     Else If "{1}" =~ /-cr/
  103.         Set type CR
  104.         Unset toollibs
  105.         If {typeSpec} == 0
  106.             Set typeSpec 1
  107.         Else
  108.             Set multipleType 1
  109.         End
  110.         shift 1 
  111.         continue
  112.     Else If "{1}" =~ /-siow/
  113.         Set type SIOW
  114.         If {typeSpec} == 0
  115.             Set typeSpec 1
  116.         Else
  117.             Set multipleType 1
  118.         End
  119.         shift 1
  120.         continue
  121.     Else If "{1}" =~ /-mc68020/
  122.         If "{cCompileOptions}" == ""
  123.             set cCompileOptions "-mc68020 "
  124.             set cppCompileOptions "-mc68020 "
  125.             set pCompileOptions "-mc68020 "
  126.         Else
  127.             set multipleHWOptions 1
  128.         End
  129.         shift 1
  130.         continue
  131.     Else If "{1}" =~ /-mc68881/
  132.         If "{cCompileOptions}" == ""
  133.             set cCompileOptions "-mc68020 -mc68881 "
  134.             set cppCompileOptions "-mc68020 -mc68881 "
  135.             set pCompileOptions "-mc68020 -mc68881 "
  136.             set hardwareFloat 1
  137.         Else
  138.             set multipleHWOptions 1    
  139.         End
  140.         shift 1
  141.         continue
  142.     Else If "{1}" =~ /-elems881/
  143.         If "{cCompileOptions}" == ""
  144.             set cCompileOptions "-mc68020 -mc68881 -elems881 "
  145.             set cppCompileOptions "-mc68020 -mc68881 -elems881 "
  146.             set pCompileOptions "-mc68020 -mc68881 -d elems881=true "
  147.             set hardwareFloat 1
  148.         Else
  149.             set multipleHWOptions 1
  150.         End
  151.         shift 1
  152.         continue
  153.     Else If "{1}" =~ /-c/
  154.         set creator "{2}"
  155.         set cseen 1
  156.         shift 2
  157.         continue
  158.     Else If "{1}" =~ /-t/
  159.         set typ "{2}"
  160.         set tseen 1
  161.         shift 2
  162.         continue
  163.     Else If "{1}" =~ /-rt/
  164.         set rtype "{2}"
  165.         set rtseen 1
  166.         shift 2
  167.         continue
  168.     Else If "{1}" =~ /-cpp/
  169.         set cppseen 1
  170.         shift 1
  171.         continue
  172.     Else If "{1}" =~ /-PO/
  173.         set objlibs 1
  174.         shift 1
  175.         continue
  176.     Else If "{1}" =~ /-SL/
  177.         set streamslib 1
  178.         shift 1
  179.         continue
  180.     Else If "{1}" =~ /-m/
  181.         set mentry "{2}"
  182.         set mseen 1
  183.         shift 2
  184.         continue
  185.     Else If "{1}" =~ /-sym/ 
  186.         set symarg {2}
  187.         set symseen 1
  188.         shift 2
  189.         continue
  190.     Else If ("{1}" =~ /≈.[acpr]/ || "{1}" =~ /≈.cp/ || "{1}" =~ /≈.cpp/)
  191.         Set sources "{sources}'{1}' "
  192.         shift 1
  193.         continue
  194.     Else If "{1}" =~ /≈.[o]/
  195.         Set objects "{objects}'{1}' "
  196.         shift 1
  197.         continue
  198.     Else If "{program}" == "" && "{1}" !~ /-≈/
  199.         Set program "{1}"
  200.         shift 1
  201.         continue 
  202.     Else If "{1}" =~ /-≈/
  203.         Echo "### {0} - ∂"{1}∂" is not an option." > Dev:StdErr
  204.         Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  205.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  206.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  207.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  208.         Exit 1
  209.     Else
  210.         Echo "### {0} - Files must end in .a, .c, .p, .cp, .cpp, .r, or .o." > Dev:StdErr
  211.         Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  212.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  213.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  214.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  215.         Exit 1
  216.     End
  217. End
  218. If {type} == DA && {symseen}
  219.     Echo "### {0} - Option -sym not supported for desk accessory." > Dev:StdErr
  220.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  221.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  222.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  223.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  224.     Exit 1
  225. End
  226. If {type} == CR && ("{rtype}" == "" || "{mentry}" == "")
  227.     Echo "### {0} - Options -rt and -m are required for code resource." > Dev:StdErr
  228.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  229.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  230.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  231.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  232.     Exit 1
  233. End
  234. If "{program}" == ""
  235.     Echo "### {0} - A program name is required." > Dev:StdErr
  236.     Echo "### {0} - Don't include the .a, .c, .cp, or .p suffix." > Dev:StdErr
  237.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  238.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  239.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  240.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  241.     Exit 1
  242. End
  243. If "{sources}" == ""
  244.     Echo "### {0} - A source file is required." > Dev:StdErr
  245.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  246.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  247.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  248.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  249.     Exit 1
  250. End
  251. If {multipleType} != 0
  252.     Echo "### {0} - Only one of Application, DA, Tool, or CR may be specified." > Dev:StdErr
  253.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  254.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  255.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  256.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  257.     Exit 1
  258. End
  259. If {multipleHWOptions} != 0
  260.     Echo "### {0} - Only one of -mc68020, -mc68881, or -elems881 may be specified." > Dev:StdErr
  261.     Echo "# Usage - {0} ([ -Application] [ -c creator ] [-sym on] | -Tool [-sym on] | ∂n ∂
  262.                     -DA | -CR -m mainEntryPoint -rt resourceType [ -t fileType ] ∂n ∂
  263.                     [ -c creator ] [-sym on] | -SIOW [ -sym on ]) ∂n ∂
  264.             [ -mc68020 | -mc68881 | -elems881] program file…" > Dev:StdErr
  265.     Exit 1
  266. End
  267.  
  268. If {cSeen} != 0 && ({type} == Tool || {type} == DA || {type} == SIOW)
  269.         Echo "### {0} - Warning: Option -c ignored for {type}." > Dev:StdErr
  270. End
  271. If {tseen} != 0 && {type} != CR
  272.         Echo "### {0} - Warning: Option -t ignored for {type}." > Dev:StdErr
  273. End
  274. If {rtseen} != 0 && {type} != CR
  275.         Echo "### {0} - Warning: Option -rt ignored for {type}." > Dev:StdErr
  276. End
  277. If {mseen} != 0 && {type} != CR
  278.         Echo "### {0} - Warning: Option -m ignored for {type}." > Dev:StdErr
  279. End
  280. If {type} == Tool
  281.     Set options "-d -c 'MPS ' -t 'MPST'"
  282. Else If {type} == Application
  283.     Set options " -t 'APPL' -c '{creator}'"
  284. Else If {type} == SIOW
  285.     Set options "-d -c '????' -t 'APPL'"
  286. End
  287.  
  288. #    Create the heading at the top of the makefile.
  289.  
  290. Begin
  291.     Echo -n '#   File:       '; Quote "{program}".make
  292.     Echo -n '#   Target:     '; Quote "{program}"
  293.     If "{sources}" =~ /≈«1,80»/
  294.         Echo -n '#   Sources:    '; Quote  {sources}
  295.     Else
  296.         Set heading '#   Sources:    '
  297.         For i In {sources}
  298.             Echo -n "{heading}"
  299.             Quote "{i}"
  300.             Set heading '#               '
  301.         End
  302.     End
  303.     Echo -n '#   Created:    '; Date
  304.     Echo
  305.     Echo
  306.  
  307. #    Create list of implicit objects
  308.  
  309.     For file in {sources}
  310.         If "{file}" =~ /≈.[acp]/ || "{file}" =~ /≈.cp/ || "{file}" =~ /≈.cpp/
  311.             Set objects "{objects} '{file}.o' "
  312.         End
  313.     End
  314.  
  315. # generate OBJECTS definitions
  316.  
  317.     quote -n OBJECTS =
  318.     If "{objects}" =~ /?«1,80»/
  319.         Echo -n " "; Quote {objects}
  320.     Else
  321.         For i In {objects}
  322.             Echo ' ∂'
  323.             Echo -n ∂t∂t; Quote -n "{i}"
  324.         End
  325.         Echo
  326.     End
  327.     Echo
  328.  
  329. #  Set up library definitions and link options    
  330.  
  331.     If {symseen} == 1
  332.         Set compileOptions "-sym {symarg}"
  333.     End
  334.     
  335.     If {hardwareFloat} == 1
  336.         Set cFloatLib '{CLibraries}Clib881.o {CLibraries}CSANELib881.o {CLibraries}Math881.o'
  337.         Set cplusFloatLib '{CLibraries}Clib881.o {CLibraries}CSANELib881.o {CLibraries}Math881.o ∂
  338.                         {CLibraries}Complex881.o' #{CLibraries}CplusLib881.o 
  339.         Set pFloatLib '{PLibraries}SANELib881.o'
  340.      End
  341.     Echo
  342.     
  343.     For file in {sources}
  344.         If "{file}" =~ /≈.c/
  345.             If {cppseen} == 1
  346.                 Set CPls 1
  347.             Else
  348.                 Set CLang 1
  349.             End
  350.         Else If "{file}" =~ /≈.cp/
  351.             Set CPls 1
  352.         Else If "{file}" =~ /≈.cpp/
  353.             Set CPls 1
  354.          Else If "{file}" =~ /≈.p/
  355.             Set plibs "{pFloatLib} ∂{PLibraries∂}PasLib.o"
  356.         End
  357.     End
  358.     
  359.     If {CPls} == 1
  360.         If {hardwareFloat} == 1
  361.             Set clibs "∂{SCLibraries∂}SCLibc881.o {cplusFloatLib}" 
  362.             Set clibs "{clibs} ∂{SCLibraries∂}SCLibcpp881.o"
  363.             If {streamslib}
  364.                 Set clibs "{clibs} ∂{SCLibraries∂}SCstreamsIO881.o"
  365.             End
  366.         Else
  367.             Set clibs "∂{SCLibraries∂}SCLibc.o {cplusFloatLib}" 
  368.             Set clibs "{clibs} ∂{SCLibraries∂}SCLibcpp.o"
  369.             If {streamslib}
  370.                 Set clibs "{clibs} ∂{SCLibraries∂}SCstreamsIO.o"
  371.             End
  372.         End
  373.         If {objlibs} == 1
  374.             Set  clibs "{clibs} ∂{Libraries∂}ObjLib.o"
  375.         End
  376.     Else If {CLang} == 1
  377.         If {hardwareFloat} == 1
  378.             Set  clibs " ∂{SCLibraries∂}SCLibc881.o {cFloatLib}" 
  379.         Else
  380.             Set  clibs " ∂{SCLibraries∂}SCLibc.o {cFloatLib}" 
  381.         End
  382.     End
  383.     
  384.     If {type} == Tool
  385.         set runtime "∂{Libraries∂}Stubs.o {runtime}"
  386.     End
  387.     
  388.     If {type} == SIOW
  389.         set runtime "∂{Libraries∂}SIOW.o {runtime}"
  390.     End
  391.     
  392.     For file in {sources}
  393.             If "{file}" =~ /≈.r/
  394.                 Set resource "{file}"
  395.             End
  396.     End
  397.     
  398.     # Generate rez call
  399.  
  400. For file in {sources}
  401.         If "{file}" =~ /≈.r/
  402.             If {type} == DA
  403.                 Quote "{program}" ƒ "{program}".make "{program}".DRVW "{file}"
  404.                 Echo -n ∂t; Quote Rez -rd -c DMOV -t DFIL -d NOASM_BUILD "{file}" -o "{program}"
  405.             Else 
  406.                 Quote "{program}" ƒƒ "{program}".make "{file}"
  407.                 Echo -n ∂t; Quote Rez "{file}" -append -o "{program}"
  408.                 If {type} == CR
  409.                     Echo -n ∂t; Quote SetFile -a B "{program}"
  410.                     Echo -n ∂t; Quote Duplicate -y "{program}" "{SystemFolder}"
  411.                 End
  412.             End
  413.         End
  414.     End
  415.     Echo
  416.  
  417.     If {type} == DA
  418.         If "{resource}" == ""
  419.             Set options "-t '????' -c '????' -rt DRVW=12 -sg '{program}'"
  420.         Else
  421.             Set options "-t '????' -c '????' -rt DRVW=0 -sg '{program}'"
  422.         End
  423.         Set DRVRruntime '{Libraries}DRVRRuntime.o'
  424.         Quote -n "{program}".DRVW ƒ "{program}".make
  425.         Echo ∂ ∂{OBJECTS∂}
  426.         Set suffix '.DRVW'
  427.     Else If {type} == CR
  428.         Quote -n "{program}" ƒƒ "{program}".make
  429.         Echo ∂ ∂{OBJECTS∂}
  430.         If {typ} == 0
  431.             set typ '????'
  432.         End
  433.         Set options "-t '{typ}' -c '{creator}' -rt '{rtype}' -m '{mentry}' ∂
  434.            -sg '{program}'"
  435.     Else
  436.         Quote -n "{program}" ƒƒ "{program}".make
  437.         Echo ∂ ∂{OBJECTS∂}
  438.     End
  439.  
  440. #    Generate Link rule.
  441.     
  442.     If {symseen} == 1
  443.         Set options "{options} -sym {symarg}"
  444.     End
  445.     Echo -n ∂t; Quote -n Link {ZLinkOpts} {options}; Echo ' ∂'
  446.     If {type} == DA
  447.         Echo -n ∂t∂t
  448.         Echo -n {DRVRRuntime}; Echo ' ∂'
  449.     End
  450.     Echo -n ∂t∂t
  451.     If {CPls} == 1
  452.         Echo -n    ∂"∂{SCLibraries∂}∂"SCMainCpp.a.o ; Echo ' ∂'
  453.     Else
  454.         Echo -n    ∂"∂{SCLibraries∂}∂"SCMainC.a.o ; Echo ' ∂'
  455.     End
  456.     Echo -n ∂t∂t
  457.     Echo -n    ∂{OBJECTS∂} ; Echo ' ∂'
  458.     For i In {clibs} {runtime} {interface} {plibs} {toollibs}
  459.         If "{i}" =~ /(≈)®1(∂{≈∂})®2(≈)®3/    # contains {}s ?
  460.             Echo -n ∂t∂t; Echo "{®1}∂"{®2}∂"{®3}" ∂∂
  461.         Else
  462.             Echo -n ∂t∂t; Quote -n "{i}"; Echo ' ∂'
  463.         End
  464.     End
  465.     Echo -n ∂t∂t; Quote -o "{program}{suffix}"
  466.     
  467. #    Generate Asm, C, C++, Pascal, and Rez rules.
  468.     If {cppseen} == 1
  469.         Set compileOptions "{compileOptions}"
  470.     End
  471.     
  472.     Set cCompileOptions {cCompileOptions} "{SCOpts} "
  473.     Set cppCompileOptions {cppCompileOptions} "{SCppOpts} "
  474.  
  475.     For file in {sources}
  476.         If "{file}" =~ /≈.a/
  477.             Quote "{file}".o ƒ "{program}".make "{file}"
  478.             Echo -n ∂t Asm "{compileOptions} "; Quote "{file}"
  479.         Else If "{file}" =~ /≈.c/ && {cppseen} == 1
  480.             Quote "{file}".o ƒ "{program}".make "{file}"
  481.             Echo -n ∂t SCpp -r "{compileOptions} {cCompileOptions}"; Quote "{file}"
  482.         Else If "{file}" =~ /≈.c/
  483.             Quote "{file}".o ƒ "{program}".make "{file}"
  484.             Echo -n ∂t SC -r "{compileOptions} {cCompileOptions}"; Quote "{file}"
  485.         Else If "{file}" =~ /≈.cp/
  486.             Quote "{file}".o ƒ "{program}".make "{file}"
  487.             Echo -n ∂t SCpp "{compileOptions} {cppCompileOptions}"; Quote "{file}"
  488.         Else If "{file}" =~ /≈.cpp/
  489.             Quote "{file}".o ƒ "{program}".make "{file}"
  490.             Echo -n ∂t SCpp "{compileOptions} {cppCompileOptions}"; Quote "{file}"
  491.         Else If "{file}" =~ /≈.p/
  492.             Quote "{file}".o ƒ "{program}".make "{file}"
  493.             Echo -n ∂t Pascal "{compileOptions} {pCompileOptions}"; Quote "{file}"
  494.         End
  495.     End
  496.     If {type} == SIOW
  497.         Quote -n "{program}"; Echo ' 'ƒƒ ∂"∂{RIncludes∂}∂"SIOW.r
  498.         Echo -n ∂t; Echo Rez -a ∂"∂{RIncludes∂}∂"SIOW.r -o "{program}"
  499.     End
  500.  
  501. End > "{program}".make
  502. Echo "{program}"
  503.  
  504.  
  505.  
  506.  
  507.  
  508.